package com.juyu.miliao.api.service;

import com.juyu.miliao.api.domain.ActiveConfiguration;
import com.juyu.miliao.api.domain.vo.ActiveConfigurationVo;
import com.juyu.miliao.api.service.cache.ActiveConfigurationCacheService;
import com.juyu.miliao.common.domain.CommonHead;
import com.juyu.miliao.common.util.VerifyUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: 卜加超
 * @Date: 2019/4/11 11:46
 * @Description:
 */
@Service
public class ActiveConfigurationService {
    @Resource
    private ActiveConfigurationCacheService activeConfigurationCacheService;

    public List<ActiveConfigurationVo> getActive(int id) {
        List<ActiveConfiguration> ActivesList = activeConfigurationCacheService.getList();
        List<ActiveConfigurationVo> list = new ArrayList<>();
        for (ActiveConfiguration activeConfiguration:ActivesList) {
            ActiveConfigurationVo activeConfigurationVo = new ActiveConfigurationVo();
            BeanUtils.copyProperties(activeConfiguration,activeConfigurationVo);
            if(id > 0){
                if(activeConfiguration.getId()==id ){
                    list.add(activeConfigurationVo);
                }
            }else {
                list.add(activeConfigurationVo);
            }
        }
        return list;
    }
}
